package com.gxlevi.bean

import com.alibaba.fastjson.JSON

case class ClickLog(
                     //频道ID
                     var channelID: String,
                     //产品类别ID
                     var categoryID: String,
                     //产品ID
                     var produceID: String,
                     //国家
                     var country: String,
                     //省份
                     var province: String,
                     //城市
                     var city: String,
                     //网络方式
                     var network: String,
                     //来源方式
                     var source: String,
                     //浏览器类型
                     var browserType: String,
                     //进入网站时间
                     var entryTime: String,
                     //离开网站时间
                     var leaveTime: String,
                     //用户的ID
                     var userID: String
                   )

object ClickLog {
  def apply(json: String): ClickLog = {

    val jsonObject = JSON.parseObject(json)

    val browserType = jsonObject.getString("browserType")
    val categoryID = jsonObject.getString("categoryID")
    val channelID = jsonObject.getString("channelID")
    val city = jsonObject.getString("city")
    val country = jsonObject.getString("country")
    val entryTime = jsonObject.getString("entryTime")
    val leaveTime = jsonObject.getString("leaveTime")
    val network = jsonObject.getString("network")
    val produceID = jsonObject.getString("produceID")
    val province = jsonObject.getString("province")
    val source = jsonObject.getString("source")
    val userID = jsonObject.getString("userID")

    ClickLog(
      channelID,
      categoryID,
      produceID,
      country,
      province,
      city,
      network,
      source,
      browserType,
      entryTime,
      leaveTime,
      userID
    )
  }

}